package org.daochong.fastdev.funcs;

import java.sql.SQLException;

import org.daochong.fastdev.Context;
import org.daochong.fastdev.Function;
import org.daochong.lang.BeanUtil;

import redis.clients.jedis.JedisCommands;

public class RedisFunction implements Function {

	public boolean is(String id) {
		return id.startsWith("redis.set.") || id.startsWith("redis.get.");
	}

	public void exec(String key, String prop, Context context) throws SQLException {
		prop = BeanUtil.formatString(prop, context);
		if (key.startsWith("redis.get.")) {
			String id = key.substring(10).trim();
			Object o = context.getUaiFactory().getTemplate(JedisCommands.class).get(prop);
			context.add(id, o);
		} else if (key.startsWith("redis.set.")) {

		}
	}

}
